package com.enwayouli.controller;

import com.enwayouli.mapper.CommentMapper;
import com.enwayouli.pojo.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ResponseBody
public class CommentController {
    @Autowired
    private CommentMapper commentMapper;
    @RequestMapping("/getComment")
    public List<Comment> getCommentByMid(@RequestParam("mid") int mid){
        return commentMapper.getCommonByMid(mid);
    }

    @RequestMapping("/addComment")
    public String addComment(int uid,String content,int mid){
        if (commentMapper.addComment(uid, content, mid)>0){
            return "添加成功";
        }
        return "添加失败";
    }

    @RequestMapping("/getCommentNum")
    public int getBlogNum(){
        return commentMapper.getNum();
    }
}
